import { Controller, Post, Get,Query, Body,BadRequestException } from '@nestjs/common';
import { success } from '@/utils';
import { MerchantsService } from './merchants.service';
 @Controller('merchants')

 export class MerchantsController {
    constructor(private readonly merchantsService: MerchantsService) {}
      @Get('findBylnglat')
      async bylnglat(@Query('longitude') longitude:any,@Query('latitude') latitude:any,) {
        try {   
            const res =  await this.merchantsService.findBylnglat(Number(longitude),Number(latitude))
            return success(res, '获取成功');
        } catch (error) {
            throw new BadRequestException('坐标不正确');
        }
      }
      @Post('findByids')
      async findByids(@Body() data:number[]) {
        try {
          if(data.length<=0)return   success([], '获取成功'); 
            const res =  await this.merchantsService.findByids(data)
            return success(res, '获取成功');
        } catch (error) {
            throw new BadRequestException('参数不正确');
        }
      }
 }